<?php

namespace Addons\CreditComment\Controller;
use Home\Controller\AddonsController;

class CreditCommentController extends AddonsController{
    var $model_name = 'credit_comment';
    public function lists($model = null, $page = 0) {
        $this->assign ( 'add_button', false );
        $this->assign ( 'del_button', false );
        $this->assign ( 'check_all', false );

        is_array ( $model ) || $model = $this->getModel ( $this->model_name );

        // 解析列表规则
        $list_data = $this->_list_grid ( $model );
        $fields = $list_data ['fields'];
        // 搜索条件
        $map = $this->_search_map ( $model, $fields );

        $list_data ['list_data'] = M ( $this->model_name )
            ->table('wp_credit_comment comment')
            ->join('wp_card_member member ON member.uid = comment.uid')
            ->join('wp_client_card client ON client.cli_card = member.number')
            ->field('listid, content, member.number as card, client.cli_name as name, client.cli_tel as tel, score1, score2, score3')
//            ->where($map)
            ->select ();
        $this->assign ( $list_data );

        $this->display ();
    }

//    public function liststest($model = null, $page = 0) {
//        $res = M ( $this->model_name )
//            ->table('wp_credit_comment comment')
//            ->join('wp_card_member member ON member.uid = comment.uid')
//            ->join('wp_client_card client ON client.cli_card = member.number')
//            ->field('listid, content, member.number as card, client.cli_name as name, client.cli_tel as tel, score1, score2, score3')
//            ->select ();
//
//        $this->ajaxReturn($res);
//    }
}
